import styles from '../styles/Home.module.css'
import BasicLayout from '../layouts/BasicLayout'
import axios from 'axios'
import { queryUserList, queryOrderList } from '../api'
import { useState, useEffect } from 'react';

function Page({ dataList1, dataList2 }) {
	const [data, setData] = useState({ hits: [] });
	console.log('从服务器读取到的数据', dataList1, dataList2)
	return (
		<BasicLayout className={styles.container}>
		    <div>test02</div>
			{dataList1.map((item) => {
				return (<div key={item.primaryId}>{item.nickName}</div>);
			})}
			{dataList2.map((item) => {
				return (<div key={item.primaryId}>{item.orderId}</div>);
			})}
		</BasicLayout>
	)
}


export async function getStaticProps() {
	const res1 = await queryUserList();//await fetch(`http://localhost:8080/user/queryUserList.do`)
	const res2 = await queryOrderList();//await fetch(`http://localhost:8080/order/queryOrderList.do`)
	const content1 = await res1.json()
	const content2 = await res2.json()
	return { 
		props: {
		    dataList1: content1.data || [], 
		    dataList2: content2.data || [], 
		}
	}
}

export default Page;